<?	

	class PaginationClassAjax

	{

		var $item_per_page;		

		

		var $ERROR = "";

		

		function clear_error()

		{

			$this->ERROR = "";

		}

		function PaginationClassAjax($item_per_page,$prev_class,$link_class,$next_class,$active_class,$adodbcon)

		{			

			$this->item_per_page=$item_per_page;	

			$this->prev_class=$prev_class;										
			$this->link_class=$link_class;										
			$this->next_class=$next_class;										
			$this->active_class=$active_class;	
			
			$this->first_class="first";	
			$this->last_class="last";

			$this->adodbcon=$adodbcon;										

		}

		function PaginationAjax($sql,$page_name,$function_name)

		{				

			global $from;

			if(empty($from))

			{

				$from=0;

			}						

			$totrec=count($this->adodbcon->GetAll($sql));



			if($totrec>0)

			{

				if($from==$totrec)

				{

					$from=$from-$this->item_per_page;

					if($from<0)

					{

						$from=0;

					}

				}

			}



			if($totrec>0)

			{

				if($totrec>$this->item_per_page)

				{

					$prev=$from-$this->item_per_page;

					$next=$from+$this->item_per_page;

					$navigation.= "";

					if (!$from==0)

					{
						$navigation.= "<li><a href=\"javascript:;\" onclick=\"$function_name('$page_name&amp;from=0')\"  title='First'>First</a></li>";
						$navigation.= "<li><a href=\"javascript:;\"  onclick=\"$function_name('$page_name&amp;from=".$prev."')\" title='Previous'>Prev</a></li>";

					}

					else

					{

						$navigation.= "";

					}

					for($i=1; $i<=ceil($totrec/$this->item_per_page);$i++)

					{

						if((($from/$this->item_per_page)+1)==$i)

						{

							$navigation.= "<li><a class='pageselect' href=\"javascript:;\"><strong>".$i."</strong></a></li>";

						}

						else

						{

							$startval=($i-1)*$this->item_per_page;

							$navigation.= "<li><a href=\"javascript:;\" onclick=\"$function_name('$page_name&amp;from=".$startval."')\">".$i."</a></li>";

						}

					}

					if($from<($totrec-$this->item_per_page))

					{

						$navigation.= "<li><a href=\"javascript:;\" onclick=\"$function_name('$page_name&amp;from=".$next."')\"  title='Next'>Next</a></li>";

						$navigation.= "<li><a href=\"javascript:;\" onclick=\"$function_name('$page_name&amp;from=".$startval."')\" title='Last'>Last</a></li>";
					}

					else

					{
						
						$navigation.= "";

					}
					

				}

			}

			$limit_sql=" LIMIT $from , ".$this->item_per_page;

			$sql=$sql.$limit_sql;

			

			$num=count($this->adodbcon->GetAll($sql));			

			$totalrecord="Total Records: ".$totrec." (Showing ".($from+1)." To ".($from+$num).") ";

			$return_arr=array($sql,$navigation,$totalrecord,$totrec);

			return $return_arr;							

		}

		function PaginationFormAjax($CategoryID="")
		{

			global $item_per_page_selected;

			global $PHP_SELF;

			?>

			<table border="0" cellspacing="0" cellpadding="0" width="20%">

			<tr>

				<td nowrap valign="top">

					<b>Records Per Page :</b>

				</td>

				<td nowrap valign="top" width="1%">&nbsp;

					

				</td>			

				<td>				

				<form name="pagination_form" action="<?=$PHP_SELF?>" method="post">

					<select name="item_per_page_form" class="form" onChange="document.pagination_form.submit()">																		

						<option value="15" <? if($_SESSION['$item_per_page_session']==15) echo "selected";?>>15</option>

						<option value="25" <? if($_SESSION['$item_per_page_session']==25) echo "selected";?>>25</option>

						<option value="35" <? if($_SESSION['$item_per_page_session']==35) echo "selected";?>>35</option>

					</select>

				</form>

				</td>

			</tr>

			</table>

			<?

		}

		

	}	



?>